package org.jrpc.proxy;

import org.jrpc.base.IClient;
import org.jrpc.base.IClientManage;
import org.springframework.beans.factory.FactoryBean;

/**
 * Created by chenyuncong on 2019/4/10.
 */
public class MyProxyFactory <T> implements FactoryBean<T> {

    private Class<T> interfaceClass;

    private IClient iClient;

    private IClientManage iClientManage;

    private String serviceName;



    public Class<T> getInterfaceClass() {
        return interfaceClass;
    }
    public void setInterfaceClass(Class<T> interfaceClass) {
        this.interfaceClass = interfaceClass;
    }
    @Override
    public T getObject() throws Exception {
        return (T) new MyProxy().bind(interfaceClass,iClientManage,serviceName);
    }

    @Override
    public Class<?> getObjectType() {
        return interfaceClass;
    }

    @Override
    public boolean isSingleton() {
        // 单例模式
        return true;
    }


    public IClient getiClient() {
        return iClient;
    }

    public void setiClient(IClient iClient) {
        this.iClient = iClient;
    }

    public IClientManage getiClientManage() {
        return iClientManage;
    }

    public void setiClientManage(IClientManage iClientManage) {
        this.iClientManage = iClientManage;
    }

    public String getServiceName() {
        return serviceName;
    }

    public void setServiceName(String serviceName) {
        this.serviceName = serviceName;
    }
}